{extend name="base"}
{block name="title"}游戏详情{/block}
{block name="head"}
<script src="__STATIC__/common/avalon.mobile-2.2.9.min.js"></script>
<style>
  ol.pkss{list-style: none;}
  ol.pkss li{text-align:center;}
  ol.pkss li i{width:20%; max-width:72px; min-width:20px; height:46px;}
  ul.nms li {width:33px; height:45px;}
  tr.OxValue td {text-align:center;}
  tr.OxValue td i {width:64px; height:28px;}
</style>
{/block}
{block name="body"}
<body ontouchstart class="mainbody ms-controller" ms-controller="GameDetail">
<!--
<ul class="nns">
  <li ms-for="(k,v) in @IMG_NIU" ms-class="['niu_'+@v]">{{k}}-{{v}}</li>
</ul>

<ul class="pks">
  <li ms-for="(k,v) in @IMG_POKER" ms-class="['pk_'+@v]">{{k}}-{{v}}</li>
</ul>

<ul class="nms">
  <li ms-for="(k,v) in @IMG_SCORE" ms-class="['num_'+@v]">{{k}}-{{v}}</li>
</ul>

<ul class="nms">
  <li ms-for="(k,v) in @IMG_SCORE" ms-class="['num_'+@v+'_win']">{{k}}-{{v}}</li>
</ul>

<ul class="nms">
  <li ms-for="(k,v) in @IMG_SCORE" ms-class="['num_'+@v+'_lose']">{{k}}-{{v}}</li>
</ul>
-->
<!--导航栏-->
<div class="location">
  <a href="javascript:history.back(-1);" class="back"><i class="iconfont icon-up"></i><span>返回上一页</span></a>
  <a href="{:url('index/home')}" class="home"><i class="iconfont icon-home"></i><span>首页</span></a>
  <i class="arrow iconfont icon-arrow-right"></i>
  <span>游戏详情</span>
</div>
<!--/导航栏-->

<div class="div-content">
  <table class="border-table" width="100%">
    <tbody>
    <tr>
      <th width="10%">RecordID：</th><td width="10%">{$RecordID}</td>
      <th width="10%">房主：</th><td width="10%"><a target="_blank" class="red" ms-attr="{href:@URL_USER_DETAIL+@TableOwner.UserID}">{{@TableOwner.NickName|escape}}({{@TableOwner.UserID}})</a></td>
      <th width="10%">房间号：</th><td width="10%">{{@RoomNum}}</td>
      <th width="10%">开房时间：</th><td width="10%">{{@PlayTime}}</td>
      <th width="10%">Kind：</th><td width="10%">{{@Kind.Name}}({{@Kind.ID}})</td>
    </tr>
    <tr>
      <th>ServerID：</th><td>{{@ServerID}}</td>
      <th>支付模式：</th><td>{{@PayMode}}</td>
      <th>人数：</th><td>{{@MaxUserCount}}</td>
      <th>局数：</th><td>{{@MaxPlayGameCount}}</td>
      <th>底分：</th><td>{{@Rule[16]/10}}</td>
    </tr>
    <tr>
      <th>游戏规则：</th>
      {/* 50=十三张|52=八张
      //坐标0: 是否加一色扑克, 0=不加; 1=加1色; 2=加2色; 3=加3色; 4=加4色; 5=加黑梅两色;

      //坐标1: 0=红五不翻倍; 1=红五翻倍;
      //坐标1: 0=红十不翻倍; 1=红十翻倍;  八张
      //坐标1: 0=不翻倍; 1=红五翻倍; 2=红十翻倍; 3=红A翻倍;

      //坐标2: 是否有特殊牌, 0=没有; 1=有;
      //坐标3: 0代表没王, 1代表2个王, 2代表4个王, 3代表6个王, 4代表8张王
      //坐标4: 顺子A-5的大小设置 都为0不需要管
      //坐标5: 打枪得分设置 默认翻倍，也不需要管
      //坐标6: 摆牌的时间, 0=不限时; 1=30秒; 2=45秒; 3=60秒; 4=20秒;
      //坐标7: 比牌动画, 0=每个人依次摊牌; 1=一起摊牌; 2=整副摊牌;
      //坐标8: 准备倒计时，0为不倒计时，1为15秒，2为30秒 3为5秒
      //坐标9: AA制付费, 1=AA支付; 2=房主支付;
      //坐标10: 连发牌 0=1连发; 1=5连发; 2=13连发; 3=3连发;
      (八张>>>坐标11: 0全牌 1为5以上的牌 2为7以上的牌)
      //坐标12: 0为单红五，1为双红五
      //坐标13: 0为普通玩法，1为冲三玩法
      //坐标16: 基础分数
      //坐标17: 踢人选项 0-可踢人 1-不可踢人
      */}
      <td colspan="9" ms-if="@Kind.ID==50||@Kind.ID==52">
          <span class="tag" title="{$u.Rule.0}">{php}
          $a = $u['Rule'][0];
          switch($a){
            case 0: $a='不加色'; break;
            case 1: $a='加1色'; break;
            case 2: $a='加2色'; break;
            case 3: $a='加3色'; break;
            case 4: $a='加4色'; break;
            case 5: $a='加黑梅两色'; break;
            default: $a=''; break;
          }
          echo($a);
          {/php}</span>
        <span class="tag" title="{$u.Rule.1}">{php}
          $a = $u['Rule'][1];
          if ($a == 0) {
            $b = '不翻倍';
          } else {
            if ($u['KindID'] == 52) {
              $b = "红十翻倍";
            } else {
              if ($a == 1) {
                $b = "红五翻倍";
              } else if ($a == 2) {
                $b = "红十翻倍";
              } else if ($a == 3) {
                $b = "红A翻倍";
              } else {
                //
              }
            }
          }
          echo($b);
          {/php}</span>
        <span class="tag" title="{$u.Rule.2}">{$u.Rule.2==0?'没':'有'}特殊牌</span>
        <span class="tag" title="{$u.Rule.3}">{$u.Rule.3 * 2}张王</span>
        <!-- <span class="tag" title="{$u.Rule.4}">{$u.Rule.4}</span> -->
        <!-- <span class="tag" title="{$u.Rule.5}">{$u.Rule.5}</span> -->
        <span class="tag" title="{$u.Rule.6}">摆牌{php}
          $a = $u['Rule'][6];
          switch($a){
            case 0: $a='不限时'; break;
            case 1: $a='限时30秒'; break;
            case 2: $a='限时45秒'; break;
            case 3: $a='限时60秒'; break;
            case 4: $a='限时20秒'; break;
            default:$a='?'; break;
          }
          echo($a);
          {/php}</span>
        <span class="tag" title="{$u.Rule.7}"><?php $a = ['依次','按墩', '整副']; $b = $u['Rule'][7]; $c = $a[$b] ?? '?'; echo($c); ?>摊牌</span>
        <span class="tag" title="{$u.Rule.8}">准备{$u.Rule.8==0?'不限时':($u.Rule.8==1?'限时15秒':($u.Rule.8==2?'限时30秒':($u.Rule.8==3?'限时5秒':'?')))}</span>
        <span class="tag" title="{$u.Rule.9}">{$u.Rule.9==1?'AA':($u.Rule.9==2?'房主':'?')}支付</span>
        <span class="tag" title="{$u.Rule.10}"><?php $a = [1,5,13,3]; $b = $u['Rule'][10];  $c = $a[$b] ?? '?'; echo($c); ?>连发</span>
        {eq name="u.KindID" value="52"}
        <span class="tag" title="{$u.Rule.11}">{$u.Rule.11==0?'全':($u.Rule.11==1?'5以上的':($u.Rule.11==2?'7以上的':'?'))}牌</span>
        {/eq}
        <span class="tag" title="{$u.Rule.12}">{$u.Rule.12==0?'单':($u.Rule.12==1?'双':'?')}红五</span>
        <span class="tag" title="{$u.Rule.13}">{$u.Rule.13==0?'普通':($u.Rule.13==1?'冲三':'?')}玩法</span>
       
      </td>
      {/* 20=房卡牛牛|30=嵊州牛牛
      //坐标0：坐庄模式 0：牛牛上庄 1：固定庄家（房主坐庄）2：自由抢庄 3：明牌抢庄 4:随机上庄 5：轮流坐庄
      //坐标1：翻倍规则 0：经典翻倍模式 1：疯狂翻倍模式
      //坐标2：赖子玩法 0：正常玩法 1：大小王赖子玩法 2：4王 3：8王
      //坐标3：特殊牌选择 0x01顺子牛 0x02同花牛 0x04葫芦牛 0x08五小牛 0x10五花牛 0x20炸弹牛 0x40同花顺
      //坐标4：底分选择 0：1/2 1：2/4 2：4/8 3：5/10 4：6/12 5：10/20
      //坐标5：花牌选择 0：有花牌 1：无花牌
      //坐标6：抢庄最大倍数 0代表无 1代表2倍 2代表3倍 3代表4倍
      */}
      <td colspan="9" ms-if="@Kind.ID==20||@Kind.ID==30||@Kind.ID==31">
        <span class="tag" title="{$u.Rule.0}">{switch name="u.Rule.0"}{case value="0"}牛牛上庄{/case}{case value="1"}房主坐庄{/case}{case value="2"}自由抢庄{/case}{case value="3"}明牌抢庄{/case}{case value="4"}随机上庄{/case}{case value="5"}轮流坐庄{/case}{default/}坐庄模式?{/switch}</span>
        <span class="tag" title="{$u.Rule.1}">{switch name="u.Rule.1"}{case value="0"}经典{/case}{case value="1"}疯狂{/case}{default/}?{/switch}翻倍模式</span>
        <span class="tag" title="{$u.Rule.2}">{switch name="u.Rule.2"}{case value="1"}2王赖子{/case}{case value="2"}4王赖子{/case}{case value="3"}8王赖子{/case}{default/}没有赖子{/switch}</span>
        <span class="tag" title="{$u.Rule.3}">{switch name="u.Rule.3"}{case value="1"}顺子牛{/case}{case value="2"}同花牛{/case}{case value="4"}葫芦牛{/case}{case value="8"}五小牛{/case}{case value="16"}五花牛{/case}{case value="32"}炸弹牛{/case}{case value="64"}同花顺{/case}{default/}无特殊牌型{/switch}</span>
        <span class="tag" title="{$u.Rule.4}">{switch name="u.Rule.4"}{case value="0"}底分1/2{/case}{case value="1"}底分2/4{/case}{case value="2"}底分4/8{/case}{case value="3"}底分5/10{/case}{case value="4"}底分6/12{/case}{case value="5"}底分10/20{/case}{default/}底分?{/switch}</span>
        <span class="tag" title="{$u.Rule.5}">{$u.Rule.5==0?'有':($u.Rule.5==1?'无':'?')}花牌</span>
        <span class="tag" title="{$u.Rule.6}">抢庄最大{switch name="u.Rule.6"}{case value="0"}0{/case}{case value="1"}2{/case}{case value="2"}3{/case}{case value="3"}4{/case}{default/}?{/switch}倍</span>
      </td>

    </tr>
    <tr>
      <td colspan="10" style="padding:0">
        <table class="border-table" width="100%">
          <thead>
          <tr><th>&nbsp;</th><th ms-for="(k,v) in @Chair" ms-css="{width:100/@MaxUserCount+'%'}">玩家[{{@k}}]</th></tr>
          </thead>
          <tbody>

          <tr><th>用户头像</th><td class="user-avatar" ms-for="(k,v) in @Chair"><a><img ms-attr="{src:v.WxHead}" /></a></td></tr>
          <tr><th>用户昵称</th><td ms-for="(k,v) in @Chair">{{v.NickName|escape}}</td></tr>
          <tr><th>用户标识</th><td ms-for="(k,v) in @Chair"><a target="_blank" ms-attr="{href:@URL_USER_DETAIL+v.UserID}" ms-if="v.UserID">{{v.UserID}}</a></td></tr>
          <tr><th>游戏标识</th><td ms-for="(k,v) in @Chair">{{v.GameID>0 ? v.GameID : ''}}</td></tr>
          <tr><th>所属代理</th><td ms-for="(k,v) in @Chair"><a target="_blank" ms-attr="{href:@URL_USER_DETAIL+v.AUserID}" class="red" ms-if="v.AUserID>0">{{v.ACompellation.length>0 ? v.ACompellation : '--'}}[{{v.AGameID}}]</a></td></tr>
          <tr><th>合计输赢</th><td ms-for="(k,v) in @Chair">{{v.Score!=999999999 ? v.Score : '-'}}</td></tr>
          <!--ms-for:(a,b) in @RecordChild-->

          <tr><th>#{{a}}</th><th ms-attr="{colspan:@MaxUserCount}" style="text-align:left">{{b.StartTime}}~{{b.EndTime}}</th></tr>

          <tr>
            <th>牌型</th>
            <td ms-for="(c,d) in @b.card">
              <ol class="pkss" ms-if="d!='_'">
                <li ms-for="(e,f) in d|card(@Kind.ID)">
                  <i ms-for="(g,h) in f" ms-class="['pk_'+h]"></i>
                </li>
              </ol>
            </td>
          </tr>

<!--          <tr ms-if="@b.OxValue" class="OxValue"><th>牛牛数值</th>-->
<!--            <td ms-for="(c,d) in @b.OxValue">-->
<!--              <i ms-if="d!='_'" ms-class="['niu_'+((d==242||d==243||d==244||d==245||d==246||d==247||d==248||d==249||d==250)?d:Math.floor((d-1)/20))]" ms-attr="{title:d+'='+Math.floor((d-1)/20)}"></i>-->
<!--            </td>-->
<!--          </tr>-->

<!--          <tr ms-if="@b.GameData.RecordGame.CallBanker"><th>叫庄分数</th><td ms-for="(c,d) in @b.GameData.RecordGame.CallBanker">{{d!='_'?d+'倍':''}}</td></tr>-->

<!--          <tr ms-if="@b.GameData.RecordGame.AddScore"><th>下注分数</th><td ms-for="(c,d) in @b.GameData.RecordGame.AddScore">{{d!='_'?d:''}}</td></tr>-->
          <tr><th>是否托管</th><td ms-for="(c,d) in @b.trustee"  style="color: red;font-size: 25px;font-style:italic;">{{d==1?'托管':''}}</td></tr>
          <tr><th>小局得分</th><td ms-for="(c,d) in @b.Score">{{d!=999999999?d:''}}</td></tr>

          <!--ms-for-end:-->
          </tbody>
        </table>
      </td>
    </tr>
    </tbody>
  </table>
</div>
<script>
  avalon.ready(function () {

    avalon.filters.json_encode = function (elm) {
      var str = JSON.stringify(elm);

      return str;
    }
    // 20=房卡牛牛; 30=嵊州牛牛; 31=欢乐牛牛; 十三张=50:3-5-5; 八张=52:2-3-3;
    avalon.filters.card = function (Card, KindID) {
      avalon.log(Card);
      var rtn = [];
      if (KindID == 50) {
        rtn.push(Card.slice(10, 13));
        rtn.push(Card.slice(5, 9));
        rtn.push(Card.slice(0, 5));
      } else if (KindID == 52) {
        rtn.push(Card.slice(6, 8));
        rtn.push(Card.slice(3, 6));
        rtn.push(Card.slice(0, 3));
      } else {
        rtn.push(Card.slice(3, 5));
        rtn.push(Card.slice(0, 3));
      }
      return rtn;
    }

    var URL_USER_AVATAR = "__STATIC__/houtai/images/dface.png";
    var URL_USER_DETAIL = "{:url('user.detail/index')}?UserID=";
    var GAME_KIND = {:json_encode($GAME_KIND, JSON_UNESCAPED_UNICODE)};
    var DATA_ALL  = {:json_encode($u, JSON_UNESCAPED_UNICODE)?:'[]'};

    var Chair = [];

    function FindUserAgent(UserID) {
      var agent = {AUserID:0, AGameID:0, ACompellation:''};
      if (UserID > 0) {
        var USER_AGENT = {:json_encode($Agent, JSON_UNESCAPED_UNICODE)};
        avalon.each(USER_AGENT, function (k, v) {
          if (v.UserID == UserID) {
            agent.AUserID = v.AUserID;
            agent.AGameID = v.AGameID;
            agent.ACompellation = v.ACompellation;
            return false;
          }
        });
      }
      return agent;
    }

    (function fixDataALL() {  // 兼容性处理
      if (
              DATA_ALL.MaxUserCount == DATA_ALL.GameID.length &&
              DATA_ALL.MaxUserCount == DATA_ALL.NickName.length &&
              DATA_ALL.MaxUserCount == DATA_ALL.Score.length &&
              DATA_ALL.MaxUserCount == DATA_ALL.UserID.length &&
              DATA_ALL.MaxUserCount == DATA_ALL.WxHead.length
      ) { // 新版-尺寸一致
        for (var i = 0; i < DATA_ALL.MaxUserCount; i++) {
          var GameID    = DATA_ALL.GameID[i];
          var NickName  = DATA_ALL.NickName[i];
          var Score     = DATA_ALL.Score[i];
          var UserID    = DATA_ALL.UserID[i];
          var WxHead    = DATA_ALL.WxHead[i];
          if (WxHead.length <= 0) {
            WxHead = URL_USER_AVATAR;
          }
          var ag = FindUserAgent(UserID);
          Chair.push({
            GameID: GameID,
            NickName: NickName,
            Score: Score,
            UserID: UserID,
            AUserID: ag.AUserID,
            AGameID: ag.AGameID,
            ACompellation: ag.ACompellation,
            WxHead: WxHead
          });
        }
      } else {  // 旧版-尺寸不同
        var arrGameID = [], arrUserID = [], arrNickName = [], arrScore = [];
        avalon.each(DATA_ALL.GameID, function (k, v) {
          if (v > 0) {
            arrGameID.push(v);
          }
        });
        avalon.each(DATA_ALL.UserID, function (k, v) {
          if (v > 0) {
            arrUserID.push(v);
          }
        });
        avalon.each(DATA_ALL.NickName, function (k, v) {
          if (v.length > 0) {
            arrNickName.push(v);
          }
        });
        avalon.each(DATA_ALL.Score, function (k, v) {
          if (v != 999999999) {
            arrScore.push(v);
          }
        });

        // 断言(DATA_ALL.WxHead == DATA_ALL.MaxUserCount)永远成立
        avalon.each(DATA_ALL.WxHead, function (idx, avatar) {
          //avalon.log(idx, avatar);
          var GameID = 0;
          var NickName = '';
          var Score = 999999999;
          var UserID = 0;
          var WxHead = URL_USER_AVATAR;
          if (avatar.length > 0) { // 该座位有数据
            GameID = arrGameID.shift();
            GameID = GameID ? GameID : 0;
            UserID = arrUserID.shift();
            UserID = UserID ? UserID : 0;
            NickName = arrNickName.shift();
            NickName = NickName ? NickName : '';
            Score = arrScore.shift();
            Score = Score ? Score : 999999999;
            WxHead = avatar;
          }
          var ag = FindUserAgent(UserID);
          Chair.push({
            GameID: GameID,
            NickName: NickName,
            Score: Score,
            UserID: UserID,
            AUserID: ag.AUserID,
            AGameID: ag.AGameID,
            ACompellation: ag.ACompellation,
            WxHead: WxHead
          });
        });
      }

    })();

    var vm = avalon.define({
      $id: "GameDetail",
      IMG_NIU: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 242, 243, 244, 245, 246, 247, 248, 249, 250],
      IMG_POKER: [
        '', '0', '00',
        '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13',
        '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29',
        '33', '34', '35', '36', '37', '38', '39', '40', '41', '42', '43', '44', '45',
        '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '60', '61',
        '78', '79'
      ],
      IMG_SCORE: ['plus', 'minus', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
      URL_USER_DETAIL: URL_USER_DETAIL,
      Chair: Chair,
      Kind: (function () {
        var kind = DATA_ALL.KindID;
        var name = GAME_KIND[kind];
        return {
          ID: kind,
          Name: name ? name : ''
        }
      })(),
      MaxPlayGameCount: DATA_ALL.MaxPlayGameCount,
      MaxUserCount: DATA_ALL.MaxUserCount,
      PayMode: DATA_ALL.PayMode,
      PlayTime: DATA_ALL.PlayTime,
      RoomNum: DATA_ALL.RoomNum,
      Rule: DATA_ALL.Rule,
      ServerID: DATA_ALL.ServerID,
      TableOwner: (function () {
        var oid = DATA_ALL.TableOwnerID;
        var usr = {UserID:oid, NickName:''};
        avalon.each(Chair, function (k, v) {
          if (v.UserID == oid) {
            usr = v;
            return false;
          }
        });
        return usr;
      })(),
      RecordChild: (function (data) {
        var t1 = new Date;
        avalon.each(data, function (idx, row) {
          var UserInfo = row.UserData;
          if (typeof(UserInfo) == 'undefined') {
            UserInfo = {UserInfo:{card:[], endScore:[]}};
          }

          row.UserInfo = UserInfo;

        });
        var t2 = new Date;
        avalon.log(data);
        return data;
      })(DATA_ALL.RecordChild)
    });

    avalon.scan(document.body);

  });
</script>
</body>
{/block}